package com.interview.controller;

import com.interview.common.Result;
import com.interview.entity.CheckCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("dataUpload")
public class DataUpload {

    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private Environment environment;

    @CrossOrigin
    @RequestMapping("validation")
    public Result validation(){
        CheckCode checkCodeNew = new CheckCode();
        checkCodeNew.setKey("A");
        checkCodeNew.setCode("878777");
        String dataCenterURL = environment.getProperty("DataCenterURL")+"checkCode/upload";
        Class responseType = String.class;
        HttpHeaders head = new HttpHeaders();
        head.add("Content-Type","application/json");
        ResponseEntity responseEntity = restTemplate.postForEntity(dataCenterURL, checkCodeNew, responseType, head);
        System.out.println(responseEntity.getBody().toString());
        return null;
    }


}
